package com.neusoft.movie.v_movies.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.neusoft.movie.v_movies.R;
import com.neusoft.movie.v_movies.activity.DayWordActivity;
import com.neusoft.movie.v_movies.activity.SearchMovieActivity;
import com.neusoft.movie.v_movies.adpater.ArticlesAdapter;
import com.neusoft.movie.v_movies.javabean.ArticlesBean;
import com.neusoft.movie.v_movies.listener.RetrofitListener;
import com.neusoft.movie.v_movies.model.ArticlesModel;

import java.util.List;

/**
 * Created by Administrator on 2017/12/25.
 */

public class ArticlesFragment  extends BaseFragment implements RetrofitListener<List<ArticlesBean>> {
    RecyclerView recyclerView;
    private ImageView button_everyday,button_add;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
        setLayout_file(R.layout.mtab03);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    void initEvents() {


        button_everyday.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(ArticlesFragment.this.getActivity(), DayWordActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    void initViews() {

        button_everyday= (ImageView) view.findViewById(R.id.button_everyday);

        recyclerView = (RecyclerView)view.findViewById(R.id.article_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    }

    @Override
    void initData() {
        ArticlesModel articlesModel = new ArticlesModel();
        articlesModel.getArticleslist(this);

    }


    @Override
    public void onSuccess(List<ArticlesBean> articlesBeen, int flag) {
        ArticlesAdapter adapter = new ArticlesAdapter(getActivity(),articlesBeen);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onFailed() {

    }

}
